package org.jsrml.sv.mob.controller.index;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.jsrml.common.util.JSONResultDTO;
import org.jsrml.core.base.dto.LoginDomanDTO;
import org.jsrml.core.index.command.LoginCommand;
import org.jsrml.sv.mob.controller.BaseController;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/loginFrom")
public class LoginController extends BaseController {

	@RequestMapping(value = "/login", method = RequestMethod.POST)
	@ResponseBody
	public JSONResultDTO login(@RequestBody LoginCommand command) {
		return null;
		/*try {
			UsernamePasswordToken token = new UsernamePasswordToken(command.getLoginName(), command.getPassword());
			Subject subject = SecurityUtils.getSubject();
			subject.login(token);
			if (subject.isAuthenticated()) {
				LoginDomanDTO dto = (LoginDomanDTO) subject.getPrincipal();
				return createSuccessResult(dto);
			} else {
				token.clear();
				return createFailResult("-1", "登录失败！", null);
			}
		} catch (Exception e) {
			return createFailResult("-1", e.getMessage(), null);
		}*/
	}
}
